<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link rel="stylesheet" href="bootstrap/css/bootstrap.css">
</head>

<body>
  <div id="app">
    <div class="panel panel-default ">
      <div class="panel-heading ">
        <h3 class="panel-title ">{{message}} </h3>
      </div>
      <div class="panel-body ">
        <h3>to do list</h3>
        <ul class="list-group">
          <li class="list-group-item" v-for="(v,index) in todos">{{v.title}}

            <i @click="deleteToDo(index)" class=" glyphicon glyphicon-remove-circle pull-right"></i>
          </li>
        </ul>
        <form v-on:submit.prevent="addNew(newToDo) ">
          <div class="form-group ">
            <input type="text " class="form-control " id=" " placeholder=" " v-model="newToDo.title ">
          </div>
          <div class="form-group ">
            <button type="submit " class="btn btn-success ">add Todos</button>
          </div>
        </form>

      </div>
      <div class="panel-footer ">

      </div>
    </div>
  </div>
  <script src="js/vue.min.js "></script>
  <script>
    new Vue({
      el: '#app',
      data: {
        message: 'hello world',
        todos: [{
          id: 1,
          title: 'learn vue'
        }, {
          id: 2,
          title: 'learn wexin'
        }],
        newToDo: {
          id: null,
          title: ''
        },
      },
      methods: {
        addNew: function(newToDo) {
          this.todos.push(newToDo);
          this.newToDo = {
            id: null,
            title: ''
          }
        },
        deleteToDo(index) {
          this.todos.splice(index, 1);
        }
      }
    })
  </script>
</body>

</html>
